<template>
	<view class="container">
		<!-- 用户信息区域 -->
		<view class="user-section">
			<view style="width: 60%;">
				<view class="user-info">
					<view class="user-name">用户名</view>
					<view class="user-id">
						<text>账号ID: 1070237</text>
					</view>
				</view>

				<!-- 统计数据区域 -->
				<view class="stats-section">
					<view class="stat-item">
						<text class="stat-number">1234.00</text>
						<text class="stat-label">余额</text>
					</view>
					<view class="stat-item">
						<text class="stat-number">99</text>
						<text class="stat-label">优惠券</text>
					</view>
					<view class="stat-item">
						<text class="stat-number">4532</text>
						<text class="stat-label">积分</text>
					</view>
				</view>
			</view>

			<view class="user-avatar">
				<image class="avatar-img" :src="userInfo.portrait || '/static/avatar.jpg'" mode="aspectFill"></image>
			</view>
		</view>

		<!-- VIP会员卡 -->
		<!-- <view class="vip-card">
			<image src="/static/member-bg.png"></image>
		</view> -->

		<!-- 功能图标区域 -->
		<!-- <view class="function-section">
			<view class="function-item" @click="navTo('/pages/collect/collect')">
				<view class="function-icon collect-icon">
					<image src="/static/icon/collect.png" style="width: 60upx;height: 60upx;"></image>
				</view>
				<text class="function-text">收藏</text>
			</view>
			<view class="function-item" @click="navTo('/pages/message/message')">
				<view class="function-icon message-icon">
					<image src="/static/icon/message.png" style="width: 60upx;height: 60upx;"></image>
				</view>
				<text class="function-text">消息</text>
			</view>
			<view class="function-item" @click="navTo('/pages/station/station')">
				<view class="function-icon station-icon">
					<image src="/static/icon/settled.png" style="width: 60upx;height: 60upx;"></image>
				</view>
				<text class="function-text">入驻</text>
			</view>
			<view class="function-item" @click="navTo('/pages/service/service')">
				<view class="function-icon service-icon">
					<image src="/static/icon/server.png" style="width: 56upx;height: 66upx;"></image>
				</view>
				<text class="function-text">客服</text>
			</view>
		</view> -->

		<!-- 分割线 -->
		<!-- <view class="divider"></view> -->

		<!-- 菜单列表 -->
		<view class="menu-section">
			<view class="menu-item" @click="">
				<view class="menu-left">
					<view class="menu-icon" style="transform: translateX(10upx);">
						<u-icon name="kefu-ermai" size="28" color="#333"></u-icon>
					</view>
					<view class="menu-text">联系客服</view>
				</view>
				<u-icon name="arrow-right" color="#aaa"></u-icon>
			</view>
			<view class="menu-item" @click="navTo('/pages/userinfo/userinfo')">
				<view class="menu-left">
					<view class="menu-icon">
						<image src="/static/icon/personal.png" style="width: 50upx;height: 50upx;"></image>
					</view>
					<view class="menu-text">个人资料</view>
				</view>
				<u-icon name="arrow-right" color="#aaa"></u-icon>
			</view>
			<view class="menu-item" @click="navTo('/pages/points/points')">
				<view class="menu-left">
					<view class="menu-icon">
						<image src="/static/icon/recharge.png" style="width: 38upx;height: 38upx;"></image>
					</view>
					<view class="menu-text">积分充值</view>
				</view>
				<u-icon name="arrow-right" color="#aaa"></u-icon>
			</view>
			<!-- <view class="menu-item" @click="navTo('/pages/points-record/points-record')">
				<view class="menu-left">
					<text class="menu-icon">📊</text>
					<text class="menu-text">积分记录</text>
				</view>
				<u-icon name="arrow-right" color="#aaa"></u-icon>
			</view> -->
			<view class="menu-item" @click="navTo('/pages/bank-card/bank-card')">
				<view class="menu-left">
					<view class="menu-icon">
						<image src="/static/icon/bank_card.png" style="width: 50upx;height: 50upx;"></image>
					</view>
					<view class="menu-text">银行卡</view>
				</view>
				<u-icon name="arrow-right" color="#aaa"></u-icon>
			</view>
			<view class="menu-item" @click="navTo('/pages/account/account')">
				<view class="menu-left">
					<view class="menu-icon">
						<image src="/static/icon/bill.png" style="width: 35upx;height: 35upx;"></image>
					</view>
					<view class="menu-text">账单</view>
				</view>
				<u-icon name="arrow-right" color="#aaa"></u-icon>
			</view>
			<view class="menu-item" @click="navTo('/pages/set/set')">
				<view class="menu-left">
					<view class="menu-icon">
						<image src="/static/icon/setup.png" style="width: 34upx;height: 34upx;"></image>
					</view>
					<view class="menu-text">设置</view>
				</view>
				<u-icon name="arrow-right" color="#aaa"></u-icon>
			</view>
		</view>
	</view>
</template>

<script>
import {
	mapState
} from 'vuex';

export default {
	data() {
		return {

		}
	},
	onLoad() {
	},
	// #ifndef MP
	onNavigationBarButtonTap(e) {
		const index = e.index;
		if (index === 0) {
			this.navTo('/pages/set/set');
		} else if (index === 1) {
			// #ifdef APP-PLUS
			const pages = getCurrentPages();
			const page = pages[pages.length - 1];
			const currentWebview = page.$getAppWebview();
			currentWebview.hideTitleNViewButtonRedDot({
				index
			});
			// #endif
			uni.navigateTo({
				url: '/pages/notice/notice'
			})
		}
	},
	// #endif
	computed: {
		...mapState(['hasLogin', 'userInfo'])
	},
	methods: {
		/**
		 * 统一跳转接口,拦截未登录路由
		 */
		navTo(url) {
			// if(!this.hasLogin){
			// 	url = '/pages/public/login';
			// }
			uni.navigateTo({
				url
			})
		},
		// 复制用户ID
		copyUserId() {
			uni.setClipboardData({
				data: '1070237',
				success: () => {
					this.$api.msg('用户ID已复制');
				}
			});
		}
	}
}  
</script>

<style lang='scss'>
page {
	background: #fff;
}

.container {
	padding: 0;
	background: #f2f2f2;
}

// 用户信息区域
.user-section {
	padding: 40upx;
	display: flex;
	justify-content: space-between;
	align-items: center;

	.user-info {
		flex: 1;

		.user-name {
			font-size: 56upx;
			font-weight: bold;
			color: #000;
			margin-bottom: 12upx;
		}

		.user-id {
			display: flex;
			align-items: center;
			gap: 16upx;

			text {
				font-size: 30upx;
				color: #666;
			}

			.copy-icon {
				width: 32upx;
				height: 32upx;
				border: 2upx solid #999;
				border-radius: 4upx;
				display: flex;
				align-items: center;
				justify-content: center;

				.copy-text {
					font-size: 20upx;
					color: #999;
				}
			}
		}
	}

	.user-avatar {
		position: relative;
		width: 30%;
		display: flex;
		justify-content: center;
		align-items: center;

		.avatar-img {
			border: 6upx solid #fff;
			width: 160upx;
			height: 160upx;
			border-radius: 50%;
			box-shadow: 0 0 10upx 4upx rgba(0, 0, 0, 0.1);
		}

		.avatar-badge {
			position: absolute;
			right: 0;
			bottom: 0;
			width: 40upx;
			height: 40upx;
			background: #1890ff;
			border-radius: 50%;
			display: flex;
			align-items: center;
			justify-content: center;
			border: 4upx solid #fff;

			.badge-icon {
				font-size: 20upx;
				color: #fff;
				font-weight: bold;
			}
		}
	}
}

// 统计数据区域
.stats-section {
	display: flex;
	justify-content: space-between;
	margin-top: 50upx;

	.stat-item {
		display: flex;
		flex-direction: column;
		align-items: center;

		.stat-number {
			font-size: 30upx;
			color: #333;
			margin-bottom: 8upx;
		}

		.stat-label {
			font-size: 24upx;
			color: #999;
		}
	}
}

// VIP会员卡
.vip-card {
	margin: 0 auto;
	width: 600upx;
	height: 160upx;
	overflow: hidden;

	image {
		transform: translateY(40upx);
		width: 100%;
		height: 100%;
	}
}

// 功能图标区域
.function-section {
	background: #fff;
	padding: 50upx 40upx 80upx;
	display: flex;
	justify-content: space-around;

	.function-item {
		display: flex;
		flex-direction: column;
		align-items: center;

		.function-icon {
			width: 100upx;
			height: 100upx;
			border-radius: 24upx;
			display: flex;
			align-items: center;
			justify-content: center;


			.icon-star,
			.icon-message,
			.icon-station,
			.icon-service {
				font-size: 36upx;
				color: #1890ff;
			}
		}

		.function-text {
			font-size: 30upx;
			color: #333;
		}
	}
}

// 分割线
.divider {
	margin: 0 30upx;
	height: 2upx;
	background: #ccc;
}

// 菜单列表
.menu-section {
	padding-top: 40upx;
	background: #fff;

	.menu-item {
		height: 100upx;
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 26upx 46upx;

		&:last-child {
			border-bottom: none;
		}

		.menu-left {
			display: flex;
			align-items: center;
			gap: 16upx;

			.menu-icon {
				width: 50upx;
				text-align: center;

				image {
					transform: translateY(6upx);
				}
			}

			.menu-text {
				font-size: 30upx;
				color: #333;
			}
		}

		.arrow {
			font-size: 32upx;
			color: #ccc;
			font-weight: 300;
		}
	}

	.menu-item:active {
		background: #edf7ff;
	}
}
</style>